﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Collab.Services.Remote.Entities
{
    [DataContract(Namespace = "http://collab.codeplex.com/2010/10/Schemas")]
    public class SelectionSpan
    {
        [DataMember(Order = 1, IsRequired = true)]
        public int Start { get; set; }
        [DataMember(Order = 1, IsRequired = true)]
        public int Length { get; set; }

        // override object.Equals
        public override bool Equals(object obj)
        {
            //       
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237  
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }

            var other = obj as SelectionSpan;
            return (this.Start == other.Start && this.Length == other.Length);
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return (Start + (Length * 20001)).GetHashCode();
        }
    }
}
